  import httpUtils from '../utils/personal.js'

// 去注册方法
function toRegister({
  _this,
  data
}) {
  console.log(data);
  _this.isLogin = !_this.isLogin
}

// 去登录方法

function login() {
        httpUtils.request({
          url: '/user/login',
          method: 'POST',
          data: {
            username: this.username,
            password: this.password
          }
        }).then(val => {
          uni.setStorage({
            key: 'token',
            data: val.token,
            success() {
              uni.showToast({
                title: '登录成功',
                duration: 1000,
                icon: 'success',
                complete() {
                  uni.switchTab({
                    url: '/pages/my/my'
                  })
                }
              })
      
            }
          })
        }, err => {
          console.log(err);
          if (err.status === 501) {
            uni.showToast({
              title: err.message,
              duration: 1000,
              icon: 'error'
            })
          }
        })
      }
module.exports = {
  toRegister,
  login,
  toRegister
}
